<template>
  <div class="myContainer">
    <el-row class="myTitleBorderBottom myMarginBottom_10px">
      <el-col :span="12" class="myLineHeight_40px">
        <span v-if="type=='add'">新增</span>
        <span v-if="type=='update'">编辑</span>
      </el-col>
    </el-row>
    <el-row class="myPaddingBottom_10px">
      <el-col :span="3" class="myLeftMsg">
        <span class="require myVA_M">*</span>
         店铺联系人:
      </el-col>
      <el-col :span="7">
        <el-input placeholder="请输入店铺联系人" v-model="CONTACTER" :readonly="is_modifly"></el-input>
      </el-col>
    </el-row>
    <el-row class="myPaddingBottom_10px">
      <el-col :span="3" class="myLeftMsg">
        <span class="require myVA_M">*</span>
         店铺联系电话:
      </el-col>
      <el-col :span="7">
        <el-input placeholder="请输入店铺联系电话" v-model="TEL" :readonly="is_modifly"></el-input>
      </el-col>
    </el-row>
    <el-row class="myPaddingBottom_10px">
      <el-col :span="3" class="myLeftMsg">
        <span class="require myVA_M">*</span>
         账户类型:
      </el-col>
      <el-col :span="7" class="myLineHeight_40px">
        <template>
          <el-radio-group v-model="accountType">
            <el-radio :label="1">支付宝</el-radio>
            <el-radio :label="2">微信</el-radio>
          </el-radio-group>
        </template>
      </el-col>
    </el-row>
    <el-row class="myPaddingBottom_10px">
      <el-col :span="3" class="myLeftMsg">
        <span class="require myVA_M">*</span>
         账户名称:
      </el-col>
      <el-col :span="7">
        <el-input placeholder="请输入账户名称" v-model="ACCOUNTNAME"></el-input>
      </el-col>
    </el-row>
    <el-row class="myPaddingBottom_10px">
      <el-col :span="3" class="myLeftMsg">
        <span class="require myVA_M">*</span>
         账户账号:
      </el-col>
      <el-col :span="7">
        <el-input placeholder="请输入账户账号" v-model="ACCOUNTNUM"></el-input>
      </el-col>
    </el-row>
    <el-row class="myPaddingBottom_10px">
      <el-col :span="7" :offset="3">
        <el-button type="primary" class="myBgGreen" v-if="type=='update'" @click="onEdit">保 存</el-button>
        <el-button type="primary" class="myBgGreen" v-if="type=='add'" @click="">新 增</el-button>
        <el-button type="primary" class="myBgGreen" @click="onBack">返 回</el-button>
      </el-col>
    </el-row>
    
  </div>
</template>
<style scoped>
  .myContainer{
    background: #fff;
    padding: 10px;
  }
  .myTitleBorderBottom{
    color: #000;
    font-weight: 500;
    font-size: 16px;
    border-bottom: 1px solid #dbdbdb;
  }
  .myBgGreen{
    background: #00c2a9;
    border-color: #00c2a9;
    color: #fff;
    margin-top:2px;
  }
  .myBgGreen:hover{
    background: #33ceba;
  }
  .myTextAlignRight{
    text-align: right;
  }
  .myLineHeight_40px{
    line-height: 40px;
  }
  .myMarginTop_10px{
    margin-top: 10px;
  }
  .myLeftMsg{
    line-height: 40px;
    text-align: right;
    padding-right: 10px;
  }
  .myPaddingBottom_10px{
    padding-bottom: 10px;
  }
  .myVA_M{
    vertical-align: middle;
  }
  .myMarginBottom_10px{
    margin-bottom: 20px;
  }
  .avatar-uploader .el-upload {
    border: 1px dashed #d9d9d9;
    border-radius: 6px;
    cursor: pointer;
    position: relative;
    overflow: hidden;
  }
  .avatar-uploader .el-upload:hover {
    border-color: #409EFF;
  }
  .avatar-uploader-icon {
    font-size: 28px;
    color: #8c939d;
    width: 178px;
    height: 178px;
    line-height: 178px;
    text-align: center;
    border:1px solid #d8dce5;
  }
  .avatar {
    width: 178px;
    height: 178px;
    display: block;
  }
</style>
<script>
  import { getShopDetail , editAccount } from '@/api/online';
  import qs from "querystring";
  export default {
    data(){
      return{
        title: "店铺店主账户信息管理",
        id: "",
        type:"",
        is_modifly:true,
        CONTACTER:"",
        TEL:"",
        ACCOUNTNAME:"",
        ACCOUNTNUM:"",
        USER_ID:"",
        accountType:1
      }
    },
    components: {
        
    },
    created(){
      document.title=this.title;
      this.id = this.$route.query.id;
      this.type = this.$route.query.type;
      if(this.type=='add'){

      }
      if(this.type=='update'){
        this.onGetShopDetail();
      }
      
    },
    methods:{     
      onEdit(){//编辑
        let vm=this;
        let params={
          STORE_ID:vm.id,
          ACCOUNTTYPE:vm.accountType,
          ACCOUNTNAME:vm.ACCOUNTNAME,
          ACCOUNTNUM:vm.ACCOUNTNUM
        }
        editAccount(qs.stringify(params)).then(response => {
          vm.$message.success("执行成功!");
          this.$router.go(-1);
        }).catch(error => {
          vm.$message.error("执行失败!");
        })
      },
      onCreate(){//添加
        
      },
      onBack(){//返回
        this.$router.go(-1);
      },
      onGetShopDetail(){
        let vm=this;
        let params={
          STORE_ID:vm.id
        }
        getShopDetail(params).then(response => {
          let res=response.data.OBJECT;
          vm.CONTACTER=res.CONTACTER;
          vm.TEL=res.TEL;
          vm.accountType=res.ACCOUNTTYPE;
          vm.ACCOUNTNAME=res.ACCOUNTNAME;
          vm.ACCOUNTNUM=res.ACCOUNTNUM;
          console.log('拉取详细成功',res);
        }).catch(error => {
          console.log('拉取详细失败',error);
        })
      }
    }
  
  }


</script>



